package com.sti.framework.models.Basics.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sti.framework.core.controller.BaseController;
import com.sti.framework.core.web.ResponseBodyEntity;
import com.sti.framework.models.Basics.data.BasicsDist;
import com.sti.framework.models.Basics.data.DistSearchWhere;
import com.sti.framework.models.Basics.mapper.BasicsDistMapper;
import com.sti.framework.models.Basics.service.BasicsDistService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;
import java.util.List;

/**
 * 模块： 基础设置 Basics
 * 表格： 字典 Dist
 *
 * @author AutoApi
 */
@RestController
@RequestMapping("/Api/Dist")
@Api(tags = "字典", value = "基础设置")
public class BasicsDistController extends BaseController<BasicsDistMapper, BasicsDist, DistSearchWhere> {

    @Inject
    private BasicsDistService distService;

    /**
     * 获取字典新
     **/
    @GetMapping("/ListAll")
    public ResponseBodyEntity<List<BasicsDist>> list(DistSearchWhere searchWhere) {
        LambdaQueryWrapper<BasicsDist> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(searchWhere.getDistModule())) {
            lambdaQueryWrapper.eq(BasicsDist::getDistModule, searchWhere.getDistModule());
        }
        return ResponseBodyEntity.success(distService.getList(lambdaQueryWrapper));
    }

}